import { lazy } from 'react';
import { Navigate } from 'react-router-dom';

// 使用懒加载优化性能
const LoginPage = lazy(() => import('../pages/user/login/index.tsx'));
const Dashboard = lazy(() => import('../pages/Dashboard/Dashboard.jsx'));
const ApiManagement = lazy(() => import('../pages/Api/ApiManagement.jsx'));
const UserManagement = lazy(() => import('../pages/user/management/UserManagement.jsx'));
const MonitorDashboard = lazy(() => import('../pages/Monitor/MonitorDashboard.jsx'));
const ApiDetail = lazy(() => import('../pages/Api/ApiDetail/index.jsx'));

// 公共路由 - 无需登录即可访问
const publicRoutes = [
  {
    path: '/login',
    element: <LoginPage />,
  },
  {
    path: '/',
    element: <Navigate to="/login" />,
  },
];

// 私有路由 - 需要登录才能访问
const privateRoutes = [
  {
    path: '/dashboard',
    element: <Dashboard />,
    name: '仪表盘',
    icon: 'home',
    access: 'dashboard',
  },
  {
    path: '/api',
    element: <ApiManagement />,
    name: 'API管理',
    icon: 'api',
    access: 'api:manage',
  },
  {
    path: '/api/:id',
    element: <ApiDetail />,
    name: 'API详情',
    hidden: true,
  },
  {
    path: '/user',
    element: <UserManagement />,
    name: '用户管理',
    icon: 'user',
    access: 'user:manage',
  },
  {
    path: '/monitor',
    element: <MonitorDashboard />,
    name: '监控统计',
    icon: 'area-chart',
    access: 'monitor:view',
  },
];

export { publicRoutes, privateRoutes };